<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>字典管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
				var reg=/^[0-9]*$/;
			$("#amount").blur(function(){
				var amount=$("#amount").val();
				if(!reg.test(amount)){
					alert("正确输入数量")
				}
			});
			$("#beginNum").blur(function(){
				var beginNum=$("#beginNum").val();
				var amount=$("#amount").val();
				if(!reg.test(beginNum)){
					alert("正确输入起始号段")
				}else if(beginNum!=""){
					var endNum=((amount-0)+(beginNum-0)-1);
					$("#endNum").val(endNum);
				}
			});
			$("#value").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					var beginNum=$("#beginNum").val();
					var amount=$("#amount").val();
					var endNum=$("#endNum").val();
					if(amount!=""&&beginNum!=""&&endNum!=""){
						if((amount-0)!=((endNum-0)-(beginNum-0)+1)){
							alert("号段值相减值不等于数量值");
							return;
						}
					}
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/app/mmsQrcode/">二维码列表</a></li>
		<li class="active"><a href="${ctx}/app/mmsQrcode/form">二维码${not empty mmsQrcode.id?'修改':'添加'}</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="mmsQrcode" action="${ctx}/app/mmsQrcode/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">活动名称</label>
			<div class="controls">
				<form:select path="activityId" class="input-medium required">
					<form:options items="${activityList}" itemLabel="activityName" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">二维码类型</label>
			<div class="controls">
				<form:select path="qrcodeType" class="input-small required">
					<form:options items="${fns:getDictList('mmsQrcode')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">活动URL</label>
			<div class="controls">
				<form:input path="qrcodeUrl" htmlEscape="false" maxlength="500" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">生成二维码数量：</label>
			<div class="controls">
				 <form:input path="amount" htmlEscape="false" maxlength="50" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">二维码号段：</label>
			<div class="controls">
				<form:input path="beginNum" htmlEscape="false" maxlength="50" class="input-small"/>~<form:input path="endNum" htmlEscape="false" maxlength="50" class="input-small"/>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>